package com.ge.boot_02_annotation;

import com.ge.boot_02_annotation.bean.Cat;
import com.ge.boot_02_annotation.bean.Dog;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class Boot02AnnotationApplication {

    public static void main(String[] args) {
        //var是JDK10提供的新特性，自动判断类型
        var ioc = SpringApplication.run(Boot02AnnotationApplication.class, args);

        for (String beanDefinitionName : ioc.getBeanDefinitionNames()) {
            System.out.println(beanDefinitionName);
        }

        Object cat01 = ioc.getBean("cat");
        Object cat02 = ioc.getBean("cat");
        System.out.println(cat01 == cat02);

        for (String s : ioc.getBeanNamesForType(Cat.class)) {
            System.out.println("cat: " + s);
        }

        for (String s : ioc.getBeanNamesForType(Dog.class)) {
            System.out.println("dog: " + s);
        }

    }

}
